package org.gd.hellojavacore.tests;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegExpTest {

    public static void main(String...args) {

        String str = "4294967296";
        System.out.println(str.matches("\\d{1,12}"));
        System.out.printf("%,.0f", Math.pow(2, 64));

        String bonusCard = "7777300098024144";
        String bonusCardPattern = "7777300\\d980\\d{5}";

        System.out.printf("\n\nbonusCard.matches: %b\n------------------------------\n",
                bonusCard.matches(bonusCardPattern));

        Pattern pattern = Pattern.compile("a.*string");
        Matcher matcher = pattern.matcher("a string");

        System.out.printf("didMatch: %b\n", matcher.matches());
        System.out.printf("patternStartIndex: %s\n", matcher.start());
        System.out.printf("patternEndIndex: %s\n", matcher.end());

        System.out.println();
        System.out.println();

        String userLogin = "+380937103721";
        String userInn = "1234567890";
        String userCard = "1234";
        System.out.printf("userLogin: %b\n", userLogin.replace("+", "").matches("^\\d{" + 12 + "}$"));
        System.out.printf("userInn: %b\n", userInn.matches("^\\d{" + 10 + "}$"));
        System.out.printf("userCard: %b\n\n", userCard.matches("^\\d{" + 4 + "}$"));
        str = "asdladl {} asda d a {} asdasd {}";
        System.out.println(str.replaceFirst("[{][}]", "1"));
    }

}
